﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace TestCenter.Forms
{
    public partial class FormResult : Form
    {
        public FormResult()
        {
            InitializeComponent();
        }

        private void FormResultLoad(object sender, EventArgs e)
        {
            var tm = Global.CurrentTestManager;
            tm.CalcResult();

            int tt = 0, td = 0;
            for (int i = 0; i < tm.Test.TotalQuestion; ++i)
            {
                var total = tm.ResultTable[i].Length;
                var done = 0;
                for (int j = 0; j < tm.ResultTable[i].Length; ++j)
                    if (tm.ResultTable[i][j].Value == true)
                        done += 1;
                string s = String.Format("{0} / {1}", done, total);
                gvResult.Rows.Add(i + 1, s, done);

                tt += total;
                td += done;
            }

            string st = String.Format("{0} / {1}", td, tt);
            gvResult.Rows.Add("Tổng", st, td);
        }

        private void FormResultFormClosed(object sender, FormClosedEventArgs e)
        {
            Dispose();

            var frm = Global.FrmUser;
            if (frm == null || frm.IsDisposed)
                frm = new FormUser();

            frm.Show();
            frm.BringToFront();
        }
    }
}
